﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YArchitech.Revit.RevitExtension;

namespace YJKRevitDimensionText.OneKeyPlanDim.DimesionDataEx
{
	public class ProSectionEx
	{
		public static List<ProSectionEx> GetAllSections(List<ProPtEx> lstProPts)
		{
			List<ProSectionEx> list = new List<ProSectionEx>();
			List<object> list2 = new List<object>();
			for (int i = 1; i < lstProPts.Count; i++)
			{
				ProPtEx proPtEx = lstProPts[i - 1];
				ProPtEx proPtEx2 = lstProPts[i];
				if (proPtEx.StartOrEndPt)
				{
					list2.Add(proPtEx.ObjectData);
				}
				else
				{
					list2.Remove(proPtEx.ObjectData);
				}
				ProSectionEx proSectionEx = new ProSectionEx();
				proSectionEx.m_lstObject.AddRange(list2);
				if (proPtEx.ProjectPt.DistanceTo(proPtEx2.ProjectPt) < ProSectionEx.ShortCurveTolerance)
				{
					proSectionEx.m_line = null;
				}
				else
				{
					try
					{
						proSectionEx.m_line = YJKLineEx.YJKGetBound(proPtEx.ProjectPt, proPtEx2.ProjectPt);
					}
					catch
					{
						proSectionEx.m_line = null;
					}
				}
				list.Add(proSectionEx);
			}
			return list;
		}

		public Line SectionLine
		{
			get
			{
				return this.m_line;
			}
		}

		public List<object> LstObject
		{
			get
			{
				return this.m_lstObject;
			}
		}

		private Line m_line;

		private List<object> m_lstObject = new List<object>();

		private static double ShortCurveTolerance = 0.0001;
	}
}
